package com.bosi.message.impl.test;

import com.bosi.message.Message;
import com.bosi.message.impl.RedisMessageService;
import io.lettuce.core.RedisClient;

import java.util.HashMap;

public class RedisMessageServicePublish {


    public static void main(String[] args) throws InterruptedException {
        RedisClient client = RedisConfig.getRedisClient();
        String game = "youyu";

        RedisMessageService messageService = new RedisMessageService(client, game);

         //系统消息
        //世界消息
        //房间消息
        //私人消息

        sendSys(messageService);
        sendWorld(messageService);
        sendRoom(messageService);
        sendUser(messageService);

        Thread.sleep(1000);
    }

    private static void sendSys(RedisMessageService messageService) {
        HashMap<String, Object> header = new HashMap<>();
        //管理员消息
        header.put("tag", "sys");
        messageService.publish(new Message(0, header,"明天上午10:00停服维护,预计停服时间2小时"));
    }

    private static void sendWorld(RedisMessageService messageService) {
        HashMap<String, Object> header = new HashMap<>();
        header.put("tag", "world");
        messageService.publish(new Message(0, header,"私聊加帮会"));
    }

    private static void sendRoom(RedisMessageService messageService) {
        HashMap<String, Object> header = new HashMap<>();
        header.put("room", "000001");
        messageService.publish(new Message(0, header,"发现敌人"));
    }

    private static void sendUser(RedisMessageService messageService) {
        HashMap<String, Object> header = new HashMap<>();
        header.put("user", "u-001");
        messageService.publish(new Message(0, header,"可以加给帮会吗"));
    }
}
